package com.tgram.android_mapapi.map;

import java.util.Map;

import com.esri.android.map.GraphicsLayer;
import com.esri.core.geometry.MultiPoint;
import com.esri.core.geometry.Point;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.PictureMarkerSymbol;
import com.esri.core.symbol.Symbol;

/**
 * @className: GraphicsLayerBase
 * @description: 画图层基类
 * @author terry_zz
 * @date 2013-6-8 上午11:14:02
 */
public class GraphicsLayerBase extends GraphicsLayer {
	// private MapView mapView;

	public int moveType = MOVE_TYPE_DEFAULT;// 地图移动的类型
	public static final int MOVE_TYPE_DEFAULT = 0;// 默认类型
	public static final int MOVE_TYPE_CORRECT = 1;// 纠错类型
	private Graphic graphic;

	public GraphicsLayerBase() {
		// this.mapView = mapView;
		super(RenderingMode.STATIC);
	}

	// public void drawPoint(double x,double y){
	// Point _Point = new Point(x, y);
	// Point _MapPoint = MapUtil.getMapPoint(_Point, mapView);
	// SimpleMarkerSymbol sms = new SimpleMarkerSymbol(Color.RED, 5,
	// STYLE.CIRCLE);
	// Graphic graphic = new Graphic(_MapPoint, sms);
	// addGraphic(graphic);
	// }
	/**
	 * 画单点
	 * 
	 * @param point
	 * @param symbol
	 */
	public int drawPoint(Point point, Symbol symbol) {
		Graphic graphic = new Graphic(point, symbol);
		return addGraphic(graphic);
	}

	/**
	 * 画单点
	 * 
	 * @param point
	 * @param symbol
	 * @param mapAttr
	 *            属性
	 */
	public int drawPoint(Point point, Symbol symbol, Map<String, Object> mapAttr) {
		Graphic graphic = new Graphic(point, symbol, mapAttr);
		return addGraphic(graphic);
	}

	/**
	 * 画graphic数组
	 * @param graphics
	 * @return
	 */
	public int[] drawPoints(Graphic[] graphics) {
		return addGraphics(graphics);
	}

	/**
	 * 画单点,点有属性数据
	 * 
	 * @param point
	 *            点位信息
	 * @param symbol
	 *            显示的symbol
	 * @param mapAttr
	 *            map集合,属性,如果不用显示属性，传null
	 * @return 该点的id
	 */
	public int drawPointIcon(Point point, PictureMarkerSymbol symbol, Map<String, Object> mapAttr) {
		Graphic graphic = new Graphic(point, symbol, mapAttr);
		return addGraphic(graphic);
	}

	/**
	 * 画多
	 * 
	 * @param multiPoint
	 * @param symbol
	 * @param mapAttr
	 * @return
	 */
	public int drawMultiPoint(MultiPoint multiPoint, Symbol symbol, Map<String, Object> mapAttr) {
		Graphic _Graphic = new Graphic(multiPoint, symbol, mapAttr);
		return addGraphic(_Graphic);
	}

	/**
	 * 画多点
	 * 
	 * @param multiPoint
	 * @param symbol
	 */
	public int drawMultiPoint(MultiPoint multiPoint, Symbol symbol) {
		Graphic _Graphic = new Graphic(multiPoint, symbol);
		return addGraphic(_Graphic);
	}

	public int getMoveType() {
		return moveType;
	}

	public void setMoveType(int moveType) {
		this.moveType = moveType;
	}

	public void setMoveTypeCorrect() {
		moveType = MOVE_TYPE_CORRECT;
	}

	public void setMoveTypeDefault() {
		moveType = MOVE_TYPE_DEFAULT;
	}

	public Map<String, Object> getAttrFromGraphic(int uid) {
		graphic = this.getGraphic(uid);
		return graphic.getAttributes();
	}
}
